package com.hgq.tenadmin.md.client.controller;

import com.github.pagehelper.PageInfo;
import com.hgq.tenadmin.md.client.param.ClientParam;
import com.hgq.tenadmin.md.client.service.MdClientService;
import com.hgq.tencommon.common.R;
import com.hgq.tencommon.entity.md.client.MdClient;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/md/client")
public class MdClientController {
    @Resource
    private MdClientService mdClientService;

    @GetMapping("/list")
    public R list(String clientName,int pageNum, int pageSize){
        PageInfo<MdClient> mdClientPageInfo = mdClientService.selectAllClient(clientName, pageNum, pageSize);
        return R.ok(mdClientPageInfo);
    }
    @GetMapping("/selectAllSalePeopleByClientName")
    public R selectAllSalePeopleByClientName(String clientName){
        System.out.println(clientName);
        List<MdClient> allClientNoPage = mdClientService.selectAllSalePeopleByClientName(clientName);
        return R.ok(allClientNoPage);
    }
    @GetMapping("/listNoPage")
    public R listNoPage(){
        List<MdClient> allClientNoPage = mdClientService.findAllClientNoPage();
        return R.ok(allClientNoPage);
    }
    @GetMapping("/seaList")
    public R seaList(String clientName,int pageNum, int pageSize){
        PageInfo<MdClient> mdClientPageInfo = mdClientService.selectSeaAllClient(clientName, pageNum, pageSize);
        return R.ok(mdClientPageInfo);
    }
    @PostMapping("/save")
    public R save(@RequestBody ClientParam clientParam){
        mdClientService.saveOneClient(clientParam);
        return R.ok();
    }
    @PostMapping("/update")
    public R update(@RequestBody ClientParam clientParam){
        mdClientService.updateOneClient(clientParam);
        return R.ok();
    }
    @GetMapping("/delete")
    public R delete(Integer cid){
        mdClientService.deleteOneClient(cid);
        return R.ok();
    }
    @GetMapping("/updateClientToSea")
    public R updateClientToSea( Integer cid){

        mdClientService.updateClientToSea(cid);
        return R.ok();
    }

}
